package org.example.everyday;

import java.util.Arrays;

/**
 * <p>
 * Description:TODO 详细描述
 * <p>
 * <p>
 *
 * @author anlu
 * @date 2022/6/13 9:21
 */
public class Lc1051 {
    public static void main(String[] args) {
        Lc1051 lc1051 = new Lc1051();

        int[] heights = {1,1,4,2,1,3};
        int res = lc1051.heightChecker(heights);
        System.out.println(res);
    }

    public int heightChecker(int[] heights) {
        int n = heights.length, ans = 0;
        int[] expected = new int[n];
        System.arraycopy(heights,0,expected,0,n);
        Arrays.sort(expected);

        for (int i = 0; i < n; i++) {
            if(heights[i] != expected[i]){
                ans++;
            }
        }
        return ans;
    }
}
